const router = require('koa-router')()
const db = require('../../assets/mysql').isconnect()

router.get('/user', async ctx => {
	let user = await db.find('*', 'user')
	let area = await db.find('*', 'area', `userid=173117002`)
	let tag = await db.find('*', 'tag', `userid=173117002`)
	ctx.body = { code: 200, result: { user, area, tag } }
})

router.post('/blog', async ctx => {
	let blog = await db.find('*', 'blog')
	ctx.body = { code: 200, result: { blog } }
})

router.post('/blogDetail', async ctx => {
	console.log(ctx.request.body)
	const { blogid } = ctx.request.body
	// console.log(blogid)
	let res = await db.find('*', 'blog', `blogid=${blogid}`)
	ctx.body = { code: 200, result: res[0] }
})
module.exports = router.routes()
